/*
 *  class CCSTransMsgWnd implement
 */

#include "stdafx.h"
#include "CSTransMsgWnd.h"

CCSTransMsgWnd::CCSTransMsgWnd() : m_hWndSnatch(0)
{}

CCSTransMsgWnd::~CCSTransMsgWnd()
{}

BOOL CCSTransMsgWnd::Create()
{
	TCHAR szWndClsName[] = TEXT("CSTransMsgWnd");
	HINSTANCE hInst;
	WNDCLASS wc;

	hInst = GetModuleHandle(0);

	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = (WNDPROC)WndProcForSnatch;
	wc.cbWndExtra = 0;
	wc.cbClsExtra = 0;
	wc.hInstance = hInst;
	wc.hIcon = NULL;
	wc.hCursor = NULL;
	wc.hbrBackground = NULL;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = szWndClsName;

	if (!RegisterClass(&wc))
		return FALSE;
	
	m_hWndSnatch = CreateWindow(szWndClsName, "haha", WS_OVERLAPPEDWINDOW, 
								0, 0, 10, 10, NULL, NULL, hInst, NULL);
	if (m_hWndSnatch == 0)
		return FALSE;

	return TRUE;
}

LRESULT CALLBACK CCSTransMsgWnd::WndProcForSnatch(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	hash_map<DWORD, HANDLE>::iterator hmp;
	DWORD dwCSProcID = (DWORD)wParam;
	switch (message)
	{
	case WM_COPYDATA:
		//MessageBox(NULL, "GET SUCCESS", "GET", MB_OK);
		hmp = hmProcIDPipeW.find(dwCSProcID);
		return (LRESULT)(hmp->second);
	}
	return DefWindowProc(hWnd, message, wParam, lParam);
}
/*-----------------------------------	*/